package com.pinc.exam;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class Menu_Adapter extends BaseAdapter {
	protected ArrayList<menu_class> items;
	protected LayoutInflater inflater;

	public Menu_Adapter(Context context) {
		inflater = LayoutInflater.from(context);
		items = new ArrayList<menu_class>();
		items.add(new menu_class(R.drawable.library, context.getResources().getString(R.string.str_library), Category_View.class));
		items.add(new menu_class(R.drawable.group, context.getResources().getString(R.string.str_group), Group_List.class));
		items.add(new menu_class(R.drawable.quiz, context.getResources().getString(R.string.str_quiz), Test_Setting.class));
		items.add(new menu_class(R.drawable.errlist, context.getResources().getString(R.string.str_errlist), Missed_List.class));
		items.add(new menu_class(R.drawable.info, context.getResources().getString(R.string.str_help), Help.class));
	}

	public Class<?> getItemClass(int position)
	{
		return items.get(position).mclass;
	}

	@Override
	public int getCount() {
		return items.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = inflater.inflate(R.layout.menu_item, null);
		((ImageView)view.findViewById(R.id.imageView1)).setImageResource(items.get(position).drawable);
		((TextView)view.findViewById(R.id.textView1)).setText(items.get(position).title);
		return view;
	}

	private class menu_class{
		private int drawable;
		private String title;
		private Class<?> mclass;
		public menu_class(int drawable, String title, Class<?> mclass) {
			super();
			this.drawable = drawable;
			this.title = title;
			this.mclass = mclass;
		}
	}

}
